package com.sixfoot;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.sixfoot.domain.User;
import com.sixfoot.server.Server;

public class App {
	public static ApplicationContext context;
	
	public static void main(String[] args) throws Exception {
		context = new ClassPathXmlApplicationContext(
				new String[]{"spring-config.xml", "spring-shiro.xml"});
//		ApplicationContext context = new FileSystemXmlApplicationContext(
//				new String[]{"spring-config.xml", "spring-shiro.xml"});
		
//		User user = new User();
//		user.setUsername("zhangsan");
//		user.setPassword("123");
		
//		UserRepository userRepository = context.getBean("userRepository", UserRepository.class); 
//		userRepository.save(user);
//		User u = userRepository.findByUsername("zhangsan");
//		System.out.println("插入时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(u.getCreateTime()));
		
//		Subject subject = SecurityUtils.getSubject();
//    	UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword());
//    	subject.login(token);
//    	
//    	Session session = SecurityUtils.getSubject().getSession();
//    	System.out.println("session值：" + session.getAttribute("user"));
//		new Server().start(9999);
		Server server = context.getBean("server", Server.class);
		server.start(8998);
	}
}
